local wdtx__lightningSkill = fk.CreateSkill {
  name = "wdtx__lightning_skill",
}

wdtx__lightningSkill:addEffect("cardskill", {
  name = "wdtx__lightning_skill",
  prompt = "#wdtx__lightning_skill",
  mod_target_filter = Util.TrueFunc,
  target_filter = function(self, player, to_select, selected, _, card)
    return #selected == 0 and self:modTargetFilter(to_select, selected, player, card, true)
  end,
  on_use = function(self,room, effect)
    local tos = effect.tos
    if #tos > 0 then
      local to = tos[1]
      local extra_reduce = effect.card:getMark("@reduce_lightning_num")
      room:setPlayerMark(to,"@lightning_num",5-extra_reduce)
      room:handleAddLoseSkills(to, "lightningTriSkill", nil, false)
    end
  end,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = effect.to
    -- local area = room:getCardArea(effect.card.id)
    -- p(area)
    -- dbg()
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      to = to,
      toArea = Card.PlayerJudge,
      moveReason = fk.ReasonJustMove,
    }
  end,
  on_nullified = function(self, room, effect)
    local to = effect.to
    room:handleAddLoseSkills(to, "-lightningTriSkill", nil, false)
    room:setPlayerMark(to,"@lightning_num",0)
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonPut,
      specialName = "self_draws" or "self_discs" or "self_cost",
    }
  end,
})


return wdtx__lightningSkill